﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class score_laoshi : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["sTittle"] = "查询分数";
            DropDownList1.Items.Insert(0, "---请选择---");
            DropDownList2.Items.Insert(0, "---请选择---");  
            //sdsKechent.SelectCommand = "SELECT [name], [xuesheng] FROM [kecheng] WHERE laoshi='" + Session["sUserName"].ToString() + "' or writer='" + Session["sUserName"].ToString() + "'";
        }

    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.Cells[5].Text == "999")
        {
            e.Row.Cells[2].Text = "-";
            e.Row.Cells[3].Text = "-";
            e.Row.Cells[4].Text = "-";
            e.Row.Cells[5].Text = "-";
            e.Row.Cells[6].Text = "等待评分";

        }

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        sdsXuesheng.SelectCommand = "SELECT [username], [username1], [id] FROM [account] WHERE " + zxdtransform(DropDownList1.SelectedValue.ToString());
        DropDownList2.Items.Insert(0, "---请选择---");  
    }
    protected string zxdtransform(string zs1)   //从mydesk转来。---由 Session["sKecheng"], Session["sKechenged"], Session["sKecheng_Voted"] 此方法还会用在学生已学章节上.
                                //在这里从kecheng.xuesheng字段生成形如username=xxx or username=xxx的条件
    {
        string zxdstring = "[username]='";
        //string zs1 = Session["sKecheng"].ToString();
        if (zs1.Length >= 2)    //如果参数zs1是空的，则返回“ ”，并退出程序。否则生成形如id=id1...id=id?的字符串
        {
            zs1 = zs1.Substring(2); //去掉前2个“,,”。
        }
        else
        {
            return "1=2";   //如果没有值，则返回一个false
        }
        int i = zs1.IndexOf(",,");
        while (i > 0)
        {
            zxdstring = zxdstring + zs1.Substring(0, i) + "' OR [username]='";
            zs1 = zs1.Substring(i + 2);
            i = zs1.IndexOf(",,");
        }
        i = zs1.IndexOf(",");
        zxdstring = zxdstring + zs1.Substring(0, i)+"'";
        return "(" + zxdstring + ")";

    }

    
}
